<?php
namespace Rac\Controller;
use Think\Controller;
class AdminController extends BaseController {
	
	
    public function index(){  

    	$data = D('Admin')->getAdminList();
    	$this->assign('data', $data);
    	$this->display();
    }
    

	public function add() {
		$groups = D('AuthGroup')->getGroups();
		$this->assign('groups', $groups);
		$this->display();
	}

    public function add_form() {
    	
    	
    	$num = D('Admin')->add_admin(I('post.username'), I('post.password'), I('post.status'), I('post.group_id'));

    	$res = array('flag'=>0, 'msg'=>'');
    	if ($num > 0) {
    		$res['flag'] = 1; 
    		$res['msg'] = L('_add_success_');
    	} else if ($num == -1) {
    		$res['flag'] = -1;
    		$res['msg'] = L('_username_repeated_');
    	}else {
    		$res['msg'] = L('_add_error_');
    	}
    	echo json_encode($res);
    }
}